/**
 * NESDroid
 * Copyright 2011 Stephen Damm (Halsafar)
 * All rights reserved.
 * shinhalsafar@gmail.com
 *
 * fceuSupport.cpp
 *
 *  Created on: Oct 12, 2010
 *      Author: halsafar
 */

#include <string.h>

#include <android/log.h>

#include "FceuSystem.h"
#include "GraphicsDriver.h"

#include "common.h"
#include "Application.h"

//ConfigFile	currentconfig;

// FCEU - handle turbo mode for fceu core but implemented externally
bool turbo = false;


// FCEU - must define
int closeFinishedMovie = false;

// FCEUD - rewind
extern int EnableAutosave;
extern int AutosaveQty; // default 4
extern int AutosaveFrequency; // default 256

extern Application Emulator;

void FCEUD_SetPalette(unsigned char index, unsigned char r, unsigned char g,
        unsigned char b)
{
     pcpal* Palette = Emulator.Palette;

     Palette[index].r = r;
     Palette[index].g = g;
     Palette[index].b = b;
     Palette[index].a = 255;
}


void FCEUD_GetPalette(unsigned char i, unsigned char *r, unsigned char *g,
        unsigned char *b)
{
     pcpal* Palette = Emulator.Palette;

     *r = Palette[i].r;
     *g = Palette[i].g;
     *b = Palette[i].b;
}


FILE *FCEUD_UTF8fopen(const char *n, const char *m)
{
    return fopen(n, m);
}


EMUFILE_FILE* FCEUD_UTF8_fstream(const char *n, const char *m)
{
	EMUFILE_FILE *p = new EMUFILE_FILE(n, m);
	return p;
}


bool FCEUD_ShouldDrawInputAids()
{
     return false;
}


// General Logging
void FCEUD_PrintError(const char *text)
{
	LOGD("NDK-FCEU: [%s]", text);
	FCEU_DispMessage((char*)text, 20);
}


void FCEUD_Message(const char *text)
{
	LOGD("NDK-FCEU: [%s]", text);
	FCEU_DispMessage((char*)text, 20);
}


void FCEUD_VideoChanged()
{

}


FCEUFILE* FCEUD_OpenArchiveIndex(ArchiveScanRecord& asr, std::string &fname, int innerIndex)
{
	return 0;
}


FCEUFILE* FCEUD_OpenArchive(ArchiveScanRecord& asr, std::string& fname, std::string* innerFilename)
{
	return 0;
}


ArchiveScanRecord FCEUD_ScanArchive(std::string fname)
{
	return ArchiveScanRecord();
}


// Netplay
int FCEUD_SendData(void *data, uint32 len)
{
    return 1;
}


int FCEUD_RecvData(void *data, uint32 len)
{
    return 0;
}


void FCEUD_NetworkClose(void)
{
}


void FCEUD_NetplayText(uint8 *text)
{
}


// lua functions
void GetMouseData(uint32 (&md)[3])
{

}


void FCEUD_EnableRewind(bool b, int rewindBankCount, int rewindFrameFrequency)
{
     EnableAutosave = (b ? 1 : 0);

     AutosaveQty = rewindBankCount;
     AutosaveFrequency = rewindFrameFrequency;
}

// dummy functions
#define DUMMY(f) void f(void) { }

DUMMY(FCEUD_HideMenuToggle)
DUMMY(FCEUD_TurboOn)
DUMMY(FCEUD_TurboOff)
DUMMY(FCEUD_TurboToggle)
DUMMY(FCEUD_SaveStateAs)
DUMMY(FCEUD_LoadStateFrom)
DUMMY(FCEUD_MovieRecordTo)
DUMMY(FCEUD_MovieReplayFrom)
DUMMY(FCEUD_ToggleStatusIcon)
DUMMY(FCEUD_DebugBreakpoint)
DUMMY(FCEUD_SoundToggle)
DUMMY(FCEUD_AviRecordTo)
DUMMY(FCEUD_AviStop)
void FCEUI_AviVideoUpdate(const unsigned char* buffer) { }
int FCEUD_ShowStatusIcon(void) { return 0; }
bool FCEUI_AviIsRecording(void) { return 0; }
bool FCEUI_AviDisableMovieMessages() { return true; }
const char *FCEUD_GetCompilerString() { return NULL; }
void FCEUI_UseInputPreset(int preset) { }
void FCEUD_SoundVolumeAdjust(int n) { }
void FCEUD_SetEmulationSpeed(int cmd) { }
bool FCEUD_PauseAfterPlayback() { }
void FCEUD_SetInput(bool fourscore, bool microphone, ESI port0, ESI port1, ESIFC fcexp) { }



